<include file="Public/head" />
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar"  menu="nrgl.tsjy" />
<style>
    #feedback_type{
    -moz-appearance: none;background: rgba(0, 0, 0, 0) url("http://img2.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 130px 5px;border: 1px solid #d7d7d7;color: #666;float: left;
    font-family: "微软雅黑";font-size: 12px;height: 26px;line-height: 26px;margin: 0 10px 10px 0;text-align: center;width: 154px;
    }
    #status{
    -moz-appearance: none;background: rgba(0, 0, 0, 0) url("http://img2.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 130px 5px;border: 1px solid #d7d7d7;color: #666;float: left;
    font-family: "微软雅黑";font-size: 12px;height: 26px;line-height: 26px;margin: 0 10px 10px 0;text-align: center;width: 154px;
    }
</style>
    <div class="mianR">
        <h3 class="yonghu">投诉建议</h3>

        <div class="feedback clearfix" style='display: block;margin-top: 15px;'>
            <div class="zhuang-tai">
                <input type="text" id="start_time" name="start_time" value="{$params.start_time}" placeholder="请选择提交时间" readonly /><em></em> 
            </div>
             <div class="zhuang-tai">
                <input type="text" id="end_time" name="end_time" value="{$params.end_time}" placeholder="请选择提交时间" readonly />
            </div>
            <select name="feedback_type" id="feedback_type">
                <option value="">请选择类型</option>
                <option value="2">投诉</option>
                <option value="1">建议</option>
            </select>
            <select name="status" id="status">
                    <option value="">请选择状态</option>
                    <option value="0">未处理</option>
                    <option value="1">已处理</option>
                </select>
            <div class="deng-ji" ><input type="text" name="keyword" value="" placeholder="车商、车商电话"/></div>
            <div class="shangSou"><input name="focus_search" class="focus-btn" type="button" value="搜索" /></div>
        </div>
        <div class="listBox" id="listBox"></div>
    </div>
    <div class="clear"></div>
    <div class="yunBei"></div>
    <div class="close_btn"></div>
    <div class="complaint_alert">
        <h4>投诉与建议回复：</h4>
        <p></p>
        <textarea id="mark"></textarea>
        <input type="hidden" value="" id="df_id">
        <input type="button" value="提交" class="submit_btn" />
    </div>
   <div class="clear"></div>
    <script type="text/javascript">

    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null)
            return unescape(r[2]);
        return null; //返回参数值
    }
    get_dealer_feedback_list();
    function get_dealer_feedback_list() {
        var url = mkUrl();
        var p = getUrlParam('p');
        if (p != null) {
            var purl = "?p=" + p;
        } else {
            var purl = "?p=1";
        }
        $.get("/DealerFeedBack/dealer_feedback_list/" + purl, url, function (data) {
            $("#listBox").html(data);
        }, "html");
    }
    function get_dealer_feedback_page(p) {
        var url = mkUrl();
        $.get("/DealerFeedBack/dealer_feedback_list/" + encodeURI("p/" + p), url, function (data) {
            $("#listBox").html(data);
        }, "html");
    }

    $("input[name='focus_search']").click(function () {
        get_dealer_feedback_list();
    });

    function mkUrl() {
        var url = "";
        var start_time = $("#start_time").val();
        var end_time = $("#end_time").val();
        var feedback_type = $("#feedback_type option:selected").val();
        var keyword = $("input[name='keyword']").val();
        var status = $("#status option:selected").val();
        if (start_time) {
            url += '&start_time=' + start_time;
        }
        if (end_time) {
            url += '&end_time=' + end_time;
        }
        if (feedback_type) {
            url += '&feedback_type=' + feedback_type;
        };
        if (keyword) {
            url += '&keyword=' + keyword;
        };
        if (status) {
           url += '&status=' + status; 
        };
        return url;
    }
    $("#start_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    });
    $("#end_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    }); 
    function reply_feedback(el){
        $(".yunBei").css("display","block");
        $(".complaint_alert").fadeIn();
        $(".close_btn").fadeIn();
        $(".complaint_alert p").html($(el).siblings("ul").find("li").eq(0).find("p").html());
        var df_id = $(el).siblings("input[name='df_id']").val();
        $("#df_id").val(df_id);
        var sHeight=$(".complaint_alert").outerHeight(true);
        $(".complaint_alert").css("marginTop",-sHeight/2);          
    }
    $(".close_btn").click(function(){
        $('#mark').val('');
        $(".complaint_alert").fadeOut();
        $(".yunBei").css("display","none");
        $(this).fadeOut();
    })
    $(".yunBei").unbind();
    $('.submit_btn').on('click',function(){
        var mark = $('#mark').val();
        var df_id =$('#df_id').val();
        if(mark == ''){
            shibai_alert('回复内容不能为空');
            return;
        }
        var param={
            'mark':mark,
            'df_id':df_id
        };
        var btn = $(".submit_btn");
        btn.attr("disabled", "disabled").css({"background": "#999", "border": "none"}).val("提交中...");
        $.post("/DealerFeedBack/reply_post",param,function(data){
            if(data.code=='200'){
                $(".complaint_alert").fadeOut();
                $(".close_btn").fadeOut();
                $('.yunBei').hide();
                btn.removeAttr("disabled style").val("提交");
                $("#li"+df_id).show();
                $("#mark"+df_id).html(data.data.mark);
                $('#mark').val('');
                $("#replytime"+df_id).html(data.data.replytime);
                $("#username"+df_id).html(data.data.username);
                $("#reply_btn"+df_id).hide();

            }else{
                shibai_alert(data.msg);
                btn.removeAttr("disabled style").val("提交");
                $('#mark').val('');
            }

        },'json');
    });
    </script>
    <include file="Public/foot" />